﻿using System;

namespace MathExpressionSolver
{
    public class Validation_Functions
    {
        //*************************************************
        //                   Methods
        //*************************************************
        #region Methods
        /// <summary>
        /// Validate that the value is an Integer
        /// </summary>
        /// <param name="value">The value to validate</param>
        /// <returns>'True' if the value is an Integer, 'False' otherwise</returns>
        public static bool IsNumeric(string value)
        {
            try
            {
                int.Parse(value);

                return true;
            }
            catch { return false; }
        }

        /// <summary>
        /// Validate that the value is a Double
        /// </summary>
        /// <param name="value">The value to validate</param>
        /// <returns>'True' if the value is a Double, 'False' otherwise</returns>
        public static bool IsDecimal(string value)
        {
            try
            {
                double.Parse(value);

                return true;
            }
            catch { return false; }
        }

        /// <summary>
        /// Validate that the value is a DateTime
        /// </summary>
        /// <param name="value">The value to validate</param>
        /// <returns>'True' if the value is a DateTime, 'False' otherwise</returns>
        public static bool IsDateTime(string value)
        {
            try
            {
                DateTime.Parse(value);

                return true;
            }
            catch { return false; }
        }

        /// <summary>
        /// Validate that the value is a Boolean
        /// </summary>
        /// <param name="value">The value to validate</param>
        /// <returns>'True' if the value is a Boolean, 'False' otherwise</returns>
        public static bool IsBoolean(string value)
        {
            try
            {
                bool.Parse(value);

                return true;
            }
            catch { return false; }
        }
        #endregion
        //*************************************************
    }
}